﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace GermoMarsil
{
    public class SpriteManager
    {
        protected Texture2D Texture;
        public Vector2 Position = Vector2.Zero;
        public Color Color = Color.White;
        public Vector2 Origin;
        public float Rotation = 0f;
        public float Scale = 1f;
        public SpriteEffects SpriteEffect;
        protected Rectangle[] rectangles;
        protected int FrameIndex = 0;

        public SpriteManager(Texture2D newTexture, int frames)
        {
            Texture = newTexture;
            int width = Texture.Width / frames;
            rectangles = new Rectangle[frames];
            for (int i = 0; i < frames; i++)
                rectangles[i] = new Rectangle(
                    i * width, 0, width, Texture.Height);
        }
        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Texture, Position, rectangles[FrameIndex], Color, Rotation, Origin, Scale, SpriteEffect, 0f);
        }
    }
}
